Ext.define('qjtravel.view.Travel', {
    extend: 'Ext.Panel',
    xtype: 'travel',

    config: {
        layout: 'card',
        items: [
            {
                xtype: 'titlebar',
                title: '旅游攻略',
                docked: 'top'
            },
            {
                xtype: 'dataview',
                //style:'margin:5px',
                store: 'Product',
                id: 'select_travel',
                flex: 3,
                emptyText: '未添加攻略',
                itemTpl: '<div class="travel">' +
                    '<img src="{picurl}"  width="100%" class="radius1" />' +
                    '<div class="travel_name alpha radius2" style="height:40px; line-height: 40px; overflow: hidden; font-size:18px;">{name}</div>' +
                    '</div>',
                listeners: {
                    painted: function (dataview) {
                        if (Ext.getStore('Product').getData().length == 0) {
                            Ext.getStore('Product').load();
                        }
                        Ext.getStore('Product').filter('ccid', 17);
                        var bodyW = document.body.clientWidth;
                        var intTime = setInterval(function () {
                            if (document.getElementsByClassName("radius1").length > 0) {
                                for (var i = 0; i < document.getElementsByClassName("radius1").length; i++) {
                                    document.getElementsByClassName("radius1")[i].setAttribute("height", bodyW / 3.5)
                                }
                                clearInterval(intTime);
                            }
                        }, 10)
                        var intTime1 = setInterval(function () {
                            if (document.getElementsByClassName("travel_name").length > 0) {
                                var imgH=dataview.down("img").dom.offsetWidth;
                                for (var i = 0; i < document.getElementsByClassName("travel_name").length; i++) {
                                    document.getElementsByClassName("travel_name")[i].setAttribute("style", "height:"+(imgH/9)+"px; line-height: "+(imgH/9)+"px; width:" + imgH+ "px; overflow: hidden")
                                }
                                clearInterval(intTime1);
                            }
                        }, 10)
                    }
                }
            }
        ]
    }
});
